unit Unit3; 

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, StdCtrls,
  Buttons, Unit1;

type

  { TForm3 }

  TForm3 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    Edit5: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure FormShow;
  private
    { private declarations }
  public
    { public declarations }
  end; 

var
  Form3: TForm3; 

implementation

{ TForm3 }

procedure TForm3.Button2Click(Sender: TObject);
begin
  Close;
end;

procedure TForm3.Button1Click(Sender: TObject);
var
  QueryString : string;
  
begin
  if Edit1.Text <> '' then
  begin
    QueryString := 'insert into proveedor(prv_nombre, prv_contacto, prv_email, prv_telefono, '
      + 'prv_direccion) values(''' + Edit1.Text + ''', ''' + Edit2.Text + ''', ''' + Edit3.Text
      + ''', ''' + Edit4.Text + ''', ''' + Edit5.Text + ''')';
      
    Form1.PQConnection1.ExecuteDirect('begin work;');
    Form1.PQConnection1.ExecuteDirect(QueryString);
    Form1.PQConnection1.ExecuteDirect('commit work;');
    
    ShowMessage('ALTA EXITOSA');
    FormShow;
  end
  else
    ShowMessage('ERROR EN EL INGRESO DE DATOS');
end;

procedure TForm3.FormShow;
begin
  Edit1.Text := '';
  Edit2.Text := '';
  Edit3.Text := '';
  Edit4.Text := '';
  Edit5.Text := '';
  
  Edit1.SetFocus;
end;

initialization
  {$I unit3.lrs}

end.

